import Vue from 'vue'
import Vuex from 'vuex'
import { setStorage, getStorage } from '../utils/storage'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: getStorage('token') || '',
    refresh_token: getStorage('refresh_token') || '',
    userInfo: {}
  },
  mutations: {
    getToken (state, token) {
      state.token = token
      setStorage('token', state.token)
    },
    getRefreshToken (state, refresh_token) {
      state.refresh_token = refresh_token
      setStorage('refresh_token', state.refresh_token)
    },
    setUserInfo (state, obj) {
      state.userInfo = obj
    }
  },
  actions: {
  },
  modules: {
  }
})
